package com.ruoyi.system.order.domain;

import lombok.Data;

import java.time.LocalDateTime;

@Data
public class OrderCommentQueryDTO {

    private Integer pageNum  = 1;
    private Integer pageSize = 10;

    private String  orderNo;

    private Long orderId;
    private String  riderName;
    private String  userOrMerchantName;
    private String  keyword;

    /** all / month / 3m / year / 2024 / 2023 / before2023 */
    private String  timeRange = "all";

    private LocalDateTime beginTime;
    private LocalDateTime endTime;

    private Integer star;       // 1‑5
    private Integer fromRole;   // 1买家 2商家

    public void resolveTimeRange() {
        LocalDateTime now = LocalDateTime.now();
        switch (timeRange) {
            case "month":
                beginTime = now.withDayOfMonth(1)
                        .withHour(0).withMinute(0).withSecond(0);
                break;

            case "3m":
                beginTime = now.minusMonths(3);
                break;

            case "year":
                beginTime = now.withDayOfYear(1)
                        .withHour(0).withMinute(0).withSecond(0);
                break;

            case "2024":
                beginTime = LocalDateTime.of(2024, 1, 1, 0, 0);
                endTime   = LocalDateTime.of(2024, 12, 31, 23, 59, 59);
                break;

            case "2023":
                beginTime = LocalDateTime.of(2023, 1, 1, 0, 0);
                endTime   = LocalDateTime.of(2023, 12, 31, 23, 59, 59);
                break;

            case "before2023":
                endTime   = LocalDateTime.of(2022, 12, 31, 23, 59, 59);
                break;

            default: // "all" 或其他
                // 不限时间，保持 beginTime/endTime 为 null
        }
    }
}
